home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Exchange
/
CD Exchange - Volume 1.iso
/
education
/
airfoil
/
airfoil.h
< prev
next >
Wrap
C/C++ Source or Header
|
1989-09-24
|
18KB
|
485 lines
/********************************************************************
* *
* Joukowski Airfoil Generator with Streamlines and Pressure *
* Distribution Algorithm *
* *
* Written by: Russell Leighton 15 March 1987 *
* Lancaster, CA *
* *
********************************************************************/
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/ports.h>
#include <exec/devices.h>
#include <devices/keymap.h>
#include <graphics/regions.h>
#include <graphics/copper.h>
#include <graphics/gels.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/gfx.h>
#include <graphics/clip.h>
#include <graphics/view.h>
#include <graphics/rastport.h>
#include <graphics/layers.h>
#include <intuition/intuition.h>
#include <hardware/blit.h>
#include <math.h>
#include <libraries/mathffp.h>
#undef NULL
#define NULL ((void *)0)
#define XMIN 0
#define YMIN 0
#define XMAX 639
#define YMAX 399
#define XCEN 320
#define YCEN 210
#define SFAC 100
#define TOL 1.0e-8
#define PENUP (PEN = 0)
#define PENDOWN (PEN = 1)
unsigned int mask = 0; /* one bit set for each open */
#define INTUITION 0x0001
#define GRAPHICS 0x0002
#define SCREEN 0x0004
#define WINDOW 0x0008
#define AREAFILL 0x0010
#define DMREQUEST 0x0020
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct IntuiMessage *message;
struct Message *GetMsg();
struct ViewPort *vp;
struct RastPort *rp;
struct Screen *s;
struct Window *w;
struct Requester AirRequest;
struct TmpRas trp;
struct AreaInfo area;
WORD buffer[625];
ULONG camber = 4,thickness = 6,angle = 0,velocity = 8;
float a,b,c,t,r,alpha;
int PEN,FILL,Continue = TRUE,mode = TRUE,title = FALSE;
long ixo,iyo;
char *about[] = {
" Airfoil Generator Utilizing the Joukowski Transformation",
" ",
" Written by: Russell Leighton",
" Lancaster, CA",
" March 1987",
" ",
" To use this program bring up the requester by double clicking",
" the right mouse button (the menu button). This requester can be",
" brought up at any time (even during plotting) by double clicking",
" the right mouse button. The requester gadgets are located and",
" described as follows.",
" ",
" Gadget Location Description",
" ------ -------- -----------",
" ",
" Quit Upper left corner Exits from program",
" Close Upper right corner Starts or continues plot",
" ShowTitle Upper center Toggles screen title bar",
" Airfoil Below ShowTitle gadget Toggles streamline/pressure plot",
" Camber Below Airfoil gadget Mid-chord camber entry",
" Thickness Below Camber gadget Mid-chord thickness entry",
" Angle Below Thickness gadget Angle of attack entry",
" Velocity Bottom edge Slider for velocity entry",
" "
};
UWORD colors[] = {
0x046, 0x000, 0xC00, 0xC60,
0xC90, 0xCC0, 0x0C0, 0x0C7,
0x0CC, 0x09C, 0x06C, 0x00C,
0x009, 0x006, 0x000, 0xCCC
};
UWORD closeimage[] = {
/* plane 0 */
0x3FFF, 0xFC00,
0x3000, 0x0C00,
0x33FF, 0xCC00,
0x33FF, 0xCC00,
0x33C3, 0xCC00,
0x33C3, 0xCC00,
0x33FF, 0xCC00,
0x33FF, 0xCC00,
0x3000, 0x0C00,
0x3FFF, 0xFC00
};
UWORD streamimage[] = {
/* plane 0 */
0x0000, 0x0000, 0x0000, 0x0000,
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
0xFFFF, 0xFFFF, 0xFFF0, 0x000F,
0xFC00, 0xFFE1, 0x003F, 0xFFFC,
0x03FF, 0xFFFE, 0x7FFF, 0xFFFE,
0x0000, 0xFFFC, 0x0000, 0x0000,
0xFFFE, 0x0003, 0xFFFF, 0xFFFF,
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
0xFFFF, 0xFFFF, 0x0000, 0x0000,
/* plane 1 */
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x00FF, 0xFFF8,
0xFFF0, 0x000F, 0xFC0F, 0xFFF1,
0x03FF, 0x001E, 0xFFC0, 0x0003,
0xFC00, 0x0001, 0x8000, 0x0001,
0xFFFF, 0x0003, 0xFFFF, 0xFFFF,
0x0001, 0xFFFC, 0xFFFE, 0x0003,
0xFFFF, 0xFFFF, 0x0000, 0x01FE,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
/* plane 2 */
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xFFFF, 0xFFFF,
0xFF00, 0x0007, 0x00FF, 0xFFF8,
0xFFF0, 0x000F, 0xFC00, 0x0001,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xFFFE, 0x0003,
0xFFFF, 0xFFFF, 0x0000, 0x01FE,
0xFFFF, 0xFE01, 0xFFFF, 0xFFFF,
0x0000, 0x0000, 0x0000, 0x0000
};
UWORD pressureimage[] = {
/* plane 0 */
0x0000, 0xFF80, 0x0007, 0x0060,
0x0038, 0x0010, 0x00C0, 0x0008,
0x0100, 0x0004, 0x0200, 0x0002,
0x0400, 0x0002, 0x0800, 0x0001,
0x1000, 0xFFE1, 0x203F, 0xFFFD,
0x43FF, 0xFFFE, 0x7FFF, 0xFFFE,
0x4000, 0xFFFD, 0x2000, 0x0001,
0x1000, 0x0002, 0x0C00, 0x0004,
0x0380, 0x0008, 0x0070, 0x0030,
0x000F, 0x00C0, 0x0000, 0xFF00,
0x0000, 0x0000, 0x0000, 0x0000,
/* plane 1 */
0x0000, 0x0000, 0x0000, 0xFF80,
0x0007, 0xFFE0, 0x003F, 0xFFF0,
0x00FF, 0xFFF8, 0x01FF, 0xFFFC,
0x03FF, 0xFFFC, 0x07FF, 0xFFFE,
0x0FFF, 0x001E, 0x1FC0, 0x0002,
0x3C00, 0x0000, 0x0000, 0x0000,
0x3FFF, 0x0002, 0x1FFF, 0xFFFE,
0x0FFF, 0xFFFC, 0x03FF, 0xFFF8,
0x007F, 0xFFF0, 0x000F, 0xFFC0,
0x0000, 0xFF00, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000
};
SHORT title_xy[] = {
0, 0,
151, 0,
151, 10,
0, 10,
0, 0
};
struct Border title_border = {
0L, 0L, /* LeftEdge, TopEdge */
1L, 1L, JAM1, /* FrontPen, BackPen, DrawMode */
5L, /* Count (no. of vertices) */
&title_xy[0], /* Pointer to coordinates */
NULL /* No NextBorder */
};
struct Image quit_image = {
0L, 0L, /* LeftEdge, TopEdge */
24L, 10L, 1L, /* Width, Height, Depth */
&closeimage[0], /* Pointer to bit image */
0x2, 0x0, /* PlanePick, PlaneOnOff */
NULL /* No other images */
};
struct Image close_image = {
0L, 0L, /* LeftEdge, TopEdge */
24L, 10L, 1L, /* Width, Height, Depth */
&closeimage[0], /* Pointer to bit image */
0x1, 0x0, /* PlanePick, PlaneOnOff */
NULL /* No other images */
};
struct Image stream_image = {
0L, 0L, /* LeftEdge, TopEdge */
32L, 22L, 3L, /* Width, Height, Depth */
&streamimage[0], /* Pointer to bit image */
0xD, 0x0, /* PlanePick, PlaneOnOff */
NULL /* No other images */
};
struct Image pressure_image = {
0L, 0L, /* LeftEdge, TopEdge */
32L, 22L, 2L, /* Width, Height, Depth */
&pressureimage[0], /* Pointer to bit image */
0x3, 0x0, /* PlanePick, PlaneOnOff */
NULL /* No other images */
};
struct Image prop_image;
struct IntuiText camber_text = {1L,1L,JAM1,2L,-11L,NULL,
(UBYTE *)"Camber (% of chord):",NULL};
struct IntuiText thick_text = {1L,1L,JAM1,2L,-11L,NULL,
(UBYTE *)"Thickness (% of chord):",NULL};
struct IntuiText angle_text = {1L,1L,JAM1,2L,-11L,NULL,
(UBYTE *)"Angle of attack (deg):",NULL};
struct IntuiText velocity_text = {1L,1L,JAM1,2L,-11L,NULL,
(UBYTE *)"+ Velocity -",NULL};
#define BUFSIZE 16
UBYTE CambBuf[BUFSIZE] = "4";
UBYTE ThicBuf[BUFSIZE] = "6";
UBYTE AnglBuf[BUFSIZE] = "0";
UBYTE UndoBuf[BUFSIZE];
struct StringInfo camber_string = {
CambBuf, /* Buffer */
UndoBuf, /* UndoBuffer */
0L, /* BufferPos */
BUFSIZE, /* MaxChars */
0L,0L, /* DispPos, UndoPos */
8L, /* NumChars */
0L,0L,0L, /* Posn Vars calc b